jQuery(document).ready(function($) {
	$('form.quform').Quform();

	// Tooltip settings
	if ($.isFunction($.fn.qtip)) {
		$('.quform-tooltip').qtip({
			content: {
				text: false
			},
			style: {
				classes: 'quform-tt ui-tooltip ui-tooltip-shadow',
				width: '180px'
			},
			position: {
				my: 'left center',
				at: 'right center'
			}
		});
	}
	
	// Changes subject to a text field when 'Other' is chosen
	var $subjectWrapper = $('.subject-input-wrapper'),
		subjectHtml = $subjectWrapper.html();
	
	$('#subject').live('change', function () {		
		if ($(this).val() == 'Other') {
			$subjectWrapper.html('<input name="subject" type="text" id="subject" value="" />');
			
			$cancelOther = $('<a>').click(function () {
				$subjectWrapper.html(subjectHtml);
				$(this).remove();
				return false;
			}).attr('href', '#').addClass('cancel-button').attr('title', 'Cancel');
			
			$subjectWrapper.append($cancelOther);
		}
	});
	
	// Preload images
	$.preloadImages([
		'https://8ffbbe80-a-61550f34-s-sites.googlegroups.com/a/magellantutoring.com/magellan-tutoring/close.png?attachauth=ANoY7cre_7hPE4rqylCosNR3qqH0Py4d5TOhqMUrjjD5eeQszrlXo1P-OQEe-uSd_ChVmqvwx9t28LBbHQP8e6Mz-acPmoGscxEVqSZR8iDVItY3xuzHjoYftWID_FEPEcA_1m-foHt-pgTwsI5R8C370wIy9gFKQs5RuG18pXSDQ30RZek-ULOOJZEidRfhTMeEItfztQnEOZ-5tKlRlRNoVbjWN6_KNQiQUSCdSln97oZgvr6DvVg%3D&attredirects=0',
		'https://8ffbbe80-a-61550f34-s-sites.googlegroups.com/a/magellantutoring.com/magellan-tutoring/success.png?attachauth=ANoY7cqeI1rVP08VJkaj8d0zfslEi09Mhvpl_f9NUOZUkviZidXKzud_89847zooqgPTqgcnexd0tWFDtJR2gDA-z4Zc39OYI4B4lg-CJuUgpWL1JJYuDc8r0RCai3SsmrymSdR1sdCKCES4K8el0jYwYOlKvyPPNpMcd_tLueyGykV3370u1-Wp5DnyYkZoFYHMoucDMWdl4B8IDsZXok-BXLLgv8rs_YFK5mDaCA6LfmZfwmq60Ag%3D&attredirects=0',
		'https://8ffbbe80-a-61550f34-s-sites.googlegroups.com/a/magellantutoring.com/magellan-tutoring/err.png?attachauth=ANoY7coThMboa6_AQj5sz8C0UZiXQHUCFAujEP20rtOQJcjNSi-Qy7YeIwXOWRJV1bmBqCLqBVgR1tjHUoF5D7xbK_C_Iw-nzurntu6KJWjJtBmt3dOk1Z_gLSt8EG9t06G1s7J7x-WP0ChbvrB81I0d8_boTmekfciXyVaG9fFbp8i35H_R3mNM2Iapi0mtJFvtQu8fBPuP98kvEHSGh5iqdj1ILa2j-Q%3D%3D&attredirects=0'
	]);
}); // End document.ready()
